/*
 * WelcomeDialog.cpp
 *
 *  Created on: Oct 27, 2012
 *      Author: johnny
 */

#include "WelcomeDialog.h"
#include "../UserSettings.h"

#include <QCommandLinkButton>

namespace ui {

WelcomeDialog::WelcomeDialog(QWidget* _parent): BaseUI() {
    parent = _parent;
}

bool WelcomeDialog::setup() {
    if(!BaseUI::setup(UI_WELCOME_SCREEN))
		return false;

	formWidget->setParent(parent);
    formWidget->setWindowFlags(Qt::Dialog);

    QCommandLinkButton *cmdDirUse = formWidget->findChild<QCommandLinkButton*>("cmdBtnUserDir");
    cmdDirUse->setText(QString::fromStdString(util::getDirAsString(util::MeasDir)));

	return true;
}

DiagAction WelcomeDialog::getSelectedAction() {
	QRadioButton* radPrevCfg	= formWidget->findChild<QRadioButton*>("btnPrevConfig");
	QRadioButton* radSelectCfg	= formWidget->findChild<QRadioButton*>("btnOpenCfgDisk");

	if(radPrevCfg->isChecked())
		return OpenPrev;
	else if(radSelectCfg->isChecked())
		return SelectCfg;
	else
		return OpenCfgMgr;
}

const std::string WelcomeDialog::getPrevCfgPath() {
	QListWidget* lstWidget = formWidget->findChild<QListWidget*>("lstKnownConfigs");
	QList<QListWidgetItem*> selected = lstWidget->selectedItems();

    std::string path;

    if(selected.size() == 1)
        path = selected[0]->text().toStdString();

	return path;
}

} /* namespace ui */
